package com.sduept.utils;

import java.io.StringWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;


public class PojoJsonXmlUtil {
	
	public static String beanToXml(Object obj,Class<?> load) throws JAXBException{
		  JAXBContext context = JAXBContext.newInstance(load);
		  Marshaller marshaller = context.createMarshaller();
		  marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
		  marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
		  StringWriter writer = new StringWriter();
		  marshaller.marshal(obj,writer);
		  return writer.toString().replace("standalone=\"yes\"", "");
	}
	
}
